import path from 'node:path'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import AutoImport from 'unplugin-auto-import/vite'
import { ElementPlusResolver, VueUseComponentsResolver } from 'unplugin-vue-components/resolvers'
import AutoComponents from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
import { checker } from 'vite-plugin-checker'

export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    checker({
      // vueTsc: true,
      eslint: {
        lintCommand: 'eslint .',
        useFlatConfig: true
      }
    }),
    AutoComponents({
      resolvers: [
        VueUseComponentsResolver(),
        ElementPlusResolver()
      ]
    }),
    AutoImport({
      vueTemplate: true,
      packagePresets: [{ package: 'lodash-es', ignore: ['default'] }],
      eslintrc: {
        enabled: true
      },
      imports: [
        // presets
        'vue',
        'vue-router',
        '@vueuse/core',
        {
          dayjs: [
            // default imports
            ['default', 'dayjs'] // import { default as axios } from 'axios',
          ]
        }
      ],
      resolvers: [ElementPlusResolver()]
    })
  ],
  base: './',
  resolve: {
    alias: {
      '@/': `${path.resolve(__dirname, 'src')}/`
    }
  },
  server: {
    port: 7001,
    host: '0.0.0.0',
    proxy: {
      // '^/get_ai_broadcast_latest': 'http://10.48.0.87:18199',
      // '^/model_infer': {
      //   target: 'http://10.48.0.87:18199',
      //   changeOrigin: true
      // },
      '^/(get_gfs_data|model_infer_nmg)/.*': 'http://10.10.50.108:8200'

    }
  }
})
